package com.spring.showcase.rss;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.feed.AbstractAtomFeedView;

import com.sun.syndication.feed.atom.Entry;
import com.sun.syndication.feed.atom.Feed;
import com.sun.syndication.feed.atom.Person;

public class AtomRss extends AbstractAtomFeedView {

    @Override
    protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
        feed.setId("asd");
        feed.setTitle("rss");
    }

    @Override
    protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
        List<Entry> entries = new ArrayList<Entry>();
        Entry item = new Entry();
        item.setTitle("message");
        List<Person> authors = new ArrayList<Person>();
        Person author = new Person();
        author.setName("rss");
        authors.add(author);
        item.setAuthors(authors);
        entries.add(item);
        return entries;

    }

}
